let s = "()[]{}"
let isValid = function(s){
    const stack = [];
    const map = {
        ')': '(',
        '}': '{',
        ']': '['
    };
    for (let i = 0; i < s.length; i++) {
        //如果是左括号
        if(s[i] in ['(', '{', '[']){
            stack.push(s[i])
        }
        //如果是右括号
        if(s[i] in [')', '}', ']']){
            if(stack.length == 0 || stack.pop() != map[s[i]]){
                return false
            }
        }
    }
}


console.log(isValid(s))